// 用户登录
function adminAjaxLogin() {
	var name = $('#loginname').val();
	var pass = $('#password').val();
	if (isEmpty(name) || isEmpty(pass)) {
		alert("请填写必要的信息");
		return;
	}
	$.ajax({
		url : rootPath + "/admin/user/adminAjaxLogin",
		data : {
			loginname : name,
			password : encrypt(name, pass)
		},
		dataType : "JSON",
		type : "POST",
		success : adminAjaxLogin_back
	});
}

function adminAjaxLogin_back(res) {
	if (res.result != JS_AJAX_SUCCESS) {
		alert(res.msg);
		return;
	}
	location.href = rootPath + "/admin/adminIndex";
}

// 用户登出
function adminAjaxLogout() {
	$.ajax({
		url : rootPath + "/admin/user/adminAjaxLogout",
		dataType : "JSON",
		type : "POST",
		success : adminAjaxLogout_back
	});
}

function adminAjaxLogout_back(res) {
	if (res.result != JS_AJAX_SUCCESS) {
		alert(res.msg);
		return;
	}
	location.href = rootPath + "/admin/adminLogin";
}

var userGrid;

// 加载用户表格数据
function adminAjaxLoadUser() {
	userGrid = $('#userGrid').datagrid({
		pagination : true,
		nowrap : false,
		striped : true,
		rownumbers : true,
		singleSelect : true,
		pageSize : 10,
		pageList : [ 10, 20, 50, 100, 150, 200 ],
		url : rootPath + "/admin/user/adminAjaxLoadUser",
		columns : [ [ {
			field : 'userLoginname',
			title : '登录名'
		}, {
			field : 'userCreateDttmStr',
			title : '创建时间'
		}, {
			field : 'userCreateIp',
			title : '创建IP'
		}, {
			field : 'userType',
			title : '类型'
		}, {
			field : 'userStatus',
			title : '状态'
		} ] ],
		toolbar : [ {
			text : '新增',
			handler : function() {
			}
		}, {
			text : '修改',
			handler : function() {
			}
		} ]
	});
}